import { Component, OnInit } from '@angular/core';
import { StorageService } from 'src/app/core/sotrage/storage.service';
import { Router, ActivatedRoute } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { MessageService } from 'src/app/core/service/message.service';
import { ApiService } from 'src/app/core/api';
import { NzMessageService } from 'ng-zorro-antd';

@Component({
    templateUrl: './projectDetail.html',
    styleUrls: ['./projectDetail.scss']
})
export class ProjectDetailComponent implements OnInit {
    del;
    s;
    result;
    isSMRZ;
    user;
    isUser;
    demoValue = 3;
    index2 = 0;
    ngOnInit() {
        this.message.setBreadcrumb({
            breadcrumbs: [
                { name: '我要检测' }
            ]
        });
        this.user = this.sto.get('user');
        if (this.user) {
            this.isSMRZ = this.user['isSMRZ'];
        }
        // this.del = this.route.snapshot.data.userDel.vulnerabilityProjectDetail;
        // this.isUser = this.route.snapshot.data.userDel.isUser;
        // this.del.startDate = this.del.startDate.replace(/-/g, ".");
        // this.del.endDate = this.del.endDate.replace(/\-/g, ".");
        // this.s = this.route.snapshot.queryParams.s;
        // this.result = this.route.snapshot.data.userDel.result;
    }
    toPorjuctInsize() {
        this.api.post('白帽参与项目', { projectId: this.del.id }).then((res: any) => {
            this.del = res.data.vulnerabilityProjectDetail;
            this.result = this.route.snapshot.data.result;
            this.getDel();
            this.msg.info('成功加入项目');
        }).catch((res) => {
            this.msg.error(res.message);
        });
    }
    getDel() {
        this.api.post('项目详情', { id: this.del.id }).then(res => {
            this.del = res['data'];
        }).catch(res => {
            this.msg.warning(res.message)
        });
    }
    setWidth(num) {
        return 100 - num + '%'
    }
    constructor(
        private sto: StorageService,
        private message: MessageService,
        private api: ApiService,
        private msg: NzMessageService,
        private route: ActivatedRoute
    ) { }
}